import { createRouter, createWebHistory } from 'vue-router'
import ScanPage from '../views/ScanPage.vue'
import MenuPage from '../views/MenuPage.vue'
import CartPage from '../views/CartPage.vue'
import OrderPage from '../views/OrderPage.vue'

const routes = [
  {
    path: '/',
    name: 'Scan',
    component: ScanPage,
    meta: { title: '扫码点餐' }
  },
  {
    path: '/menu/:tableId',
    name: 'Menu',
    component: MenuPage,
    meta: { title: '菜品选择' }
  },
  {
    path: '/cart/:tableId',
    name: 'Cart',
    component: CartPage,
    meta: { title: '购物车' }
  },
  {
    path: '/order/:tableId',
    name: 'Order',
    component: OrderPage,
    meta: { title: '订单确认' }
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

router.beforeEach((to, from, next) => {
  document.title = to.meta.title || '扫码点餐系统'
  next()
})

export default router 